package com.hwhhhh.mygrad.fragment;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.hwhhhh.mygrad.R;
import com.hwhhhh.mygrad.dto.UserDTO;
import com.hwhhhh.mygrad.utils.StringUtils;
import com.hwhhhh.mygrad.view.IconfontView;

public class UserNameFragment extends BaseFragment implements View.OnClickListener{
    private TextView tvSave, tvHeader;
    private EditText etName;
    private IconfontView icClose;
    private UserDTO user;

    @Override
    protected int initLayout() {
        return R.layout.fragment_user_name;
    }

    @Override
    protected void initView() {
        tvSave = getActivity().findViewById(R.id.tv_save);
        etName = mRootView.findViewById(R.id.et_user_name);
        tvHeader = getActivity().findViewById(R.id.tv_header);
        icClose = mRootView.findViewById(R.id.ic_close);
    }

    @Override
    protected void initData() {
        user = StringUtils.fromJson(getStringFromSp("user"), UserDTO.class);
        tvSave.setVisibility(View.VISIBLE);
        tvHeader.setText("修改昵称");
        icClose.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.ic_close) {
            etName.setText("");
        }
    }
}
